package gc3d.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Calendar;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;

public class TestJSON extends HttpServlet {
	private static final long serialVersionUID = 1L;

	// http://www.json.org/java/simple.txt
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		resp.setContentType("text/html");
		PrintWriter out = resp.getWriter();
		JSONObject myJSONobj   = new JSONObject();
		myJSONobj.put("taskID", "task-uuid-ok");
		myJSONobj.put("error", "no error");
		out.print("<html><div id=\"JSON\">");
		out.print("["+myJSONobj+",{\"time\":\""+Calendar.getInstance().getTimeInMillis()+"\"}]");
		out.print("</div></html>");
	}
}
